/*
 * Copyright 2010 Michael Nitsche
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package de.mnit.basis.daten;

import java.lang.reflect.Array;

import de.mnit.basis.fehler.Fehler;


/**
 * @author Michael Nitsche
 * 24.11.2010	Erstellt
 */
public class WandleArray {

	public static String[] zuStringArray(int... ia) {
		Fehler.objekt.wenn_Null(ia);
		String[] erg=new String[ia.length];
		for(int i=0; i<ia.length; i++)
			erg[i]=""+ia[i];
		return erg;
	}

	public static String[] zuStringArray(Object[] oa) {
		Fehler.objekt.wenn_Null(oa);
		String[] erg=new String[oa.length];
		for(int i=0; i<oa.length; i++)
			erg[i]=WandleObjekt.zuText(oa[i]);
		return erg;
	}

	public static String zuString(String trenner, Object array) {
		String erg="";
		int len=Array.getLength(array);
		for(int i=0; i<len-1; i++)
			erg+=Array.get(array, i)+trenner;
		if(len>0)
			erg+=Array.get(array, len-1);
		return erg;
	}

	public static int[] zuIntArray(Integer[] ia) {
		Fehler.objekt.wenn_Null((Object)ia);
		int[] erg=new int[ia.length];
		for(int i=0; i<ia.length; i++)
			erg[i]=ia[i];
		return erg;
	}

}
